package com.nuotu.datawall.clouddata.util;

import com.github.abel533.echarts.Title;
import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.Orient;
import com.github.abel533.echarts.code.Position;
import com.github.abel533.echarts.code.SeriesType;
import com.github.abel533.echarts.code.Trigger;
import com.github.abel533.echarts.code.X;
import com.github.abel533.echarts.code.Y;
import com.github.abel533.echarts.json.GsonOption;
import com.github.abel533.echarts.series.Line;
import com.github.abel533.echarts.series.Pie;
import com.github.abel533.echarts.style.ItemStyle;

import java.util.List;
import java.util.Map;

public class EPieOptionUtil {

    public static GsonOption getPieOptions(List<Map> data,boolean showCenterData) {
        GsonOption option = new GsonOption();
        if(showCenterData){
            option.setTitle(new Title().text("reader").show(false));
        }
//        option.tooltip().trigger(Trigger.item).formatter("{a} <br/>{b}: {c}").textStyle().fontSize(25);
        option.legend().left("54%").orient(Orient.vertical).x(X.right).y(Y.center).textStyle().color("0efcff").fontSize(20);
        Pie pie = new Pie();

        pie.type(SeriesType.pie).radius("50%","70%").name("").center("30%","50%").
                avoidLabelOverlap(false).label().normal().show(false).position(Position.center);
        pie.label().emphasis().show(true).textStyle().fontSize(28).fontWeight("bold");
        if(showCenterData){
            pie.label().emphasis().formatter("{d}%");
        }else {
            pie.label().emphasis().formatter("");
        }
        pie.setData(data);
        option.series(pie);
        if(showCenterData){
            option.color("#3FB1E3","#6BE6C1","#626C91","#A0A7E6","#C4EBAD","#96DEE8");
        }else {
            option.color("#3FB1E3","#626C91","#6BE6C1","#A0A7E6","#C4EBAD","#96DEE8");
        }
        return option;
    }
}